import { createAction } from 'redux-actions'
import { UPDATEPAGECHOOSEJOBAREA } from '../types/pagechoosejobarea'
import { getAreaListByCityName } from '../../../../service/user-controller'

export const DOREQUESTCHOOSEJOBAREA = createAction(UPDATEPAGECHOOSEJOBAREA, (payload) => {
  return new Promise((resolve) => {
    getAreaListByCityName(payload).then(({ data }) => {
      const { networkerror, entry, status, message } = data
      if (networkerror) {
        resolve({
          networkerror: true
        })
      } else {
        resolve({
          networkerror: false,
          showEmpty: false,
          areaList: entry
        })
      }
    })
  })
})
